package Finance::NSCC::Insurance::Schema::Contract;

use strict;
use warnings;

use base 'DBIx::Class';

__PACKAGE__->load_components("Core");
__PACKAGE__->table("contracts");
__PACKAGE__->add_columns(
  "nscc_num",
  { data_type => "CHAR", default_value => "", is_nullable => 0, size => 4 },
  "contract_num",
  { data_type => "VARCHAR", default_value => "", is_nullable => 0, size => 30 },
  "cusip",
  { data_type => "CHAR", default_value => "", is_nullable => 0, size => 9 },
  "original_contract_num",
  {
    data_type => "VARCHAR",
    default_value => undef,
    is_nullable => 1,
    size => 30,
  },
  "group_num",
  {
    data_type => "VARCHAR",
    default_value => undef,
    is_nullable => 1,
    size => 30,
  },
  "erc_id",
  {
    data_type => "VARCHAR",
    default_value => undef,
    is_nullable => 1,
    size => 20,
  },
  "erc_id_q",
  { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 2 },
  "prod_type_code",
  { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 3 },
  "comm_opt",
  {
    data_type => "VARCHAR",
    default_value => undef,
    is_nullable => 1,
    size => 30,
  },
  "comm_ext",
  {
    data_type => "VARCHAR",
    default_value => undef,
    is_nullable => 1,
    size => 10,
  },
  "dist_acct_num",
  {
    data_type => "VARCHAR",
    default_value => undef,
    is_nullable => 1,
    size => 30,
  },
  "irs_q_code",
  { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 4 },
  "contract_state",
  { data_type => "CHAR", default_value => undef, is_nullable => 1, size => 2 },
  "owner_state",
  { data_type => "CHAR", default_value => undef, is_nullable => 1, size => 2 },
  "app_signed_state",
  { data_type => "CHAR", default_value => undef, is_nullable => 1, size => 2 },
  "fund_tfr_rest_i",
  { data_type => "TINYINT", default_value => undef, is_nullable => 1, size => 1 },
  "fund_tfr_rest_reason",
  { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 2 },
  "agent_authz_i",
  { data_type => "TINYINT", default_value => undef, is_nullable => 1, size => 1 },
  "policy_effective_d",
  { data_type => "DATE", default_value => undef, is_nullable => 1, size => 10 },
);
__PACKAGE__->set_primary_key("nscc_num", "contract_num");


__PACKAGE__->has_many(agents  => 'Finance::NSCC::Insurance::Schema::Agent',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                      }
                     );

__PACKAGE__->has_many(parties => 'Finance::NSCC::Insurance::Schema::Party',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                      }
                     );

__PACKAGE__->has_many(dates   => 'Finance::NSCC::Insurance::Schema::ContractDate',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                      }
                     );

__PACKAGE__->has_many(events  => 'Finance::NSCC::Insurance::Schema::ContractEvent',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                      }
                     );

__PACKAGE__->has_many(commissions  => 'Finance::NSCC::Insurance::Schema::Commission',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                      }
                     );

__PACKAGE__->has_many(transactions => 'Finance::NSCC::Insurance::Schema::Transaction',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                      }
                     );

__PACKAGE__->has_many(valuations   => 'Finance::NSCC::Insurance::Schema::ContractValuation',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                      }
                     );

__PACKAGE__->has_many(underlying_assets => 'Finance::NSCC::Insurance::Schema::UnderlyingAsset',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                      }
                     );

__PACKAGE__->has_many(annuitization_payouts => 'Finance::NSCC::Insurance::Schema::AnnuitizationPayout',
                      {
                       'foreign.nscc_num'     => 'self.nscc_num',
                       'foreign.contract_num' => 'self.contract_num',
                      }
                     );

1;
